import { useRoute, useRouter } from 'vue-router'
export default function () {
  const router = useRouter()
  const route = useRoute()
  //   console.log(route)
  const ROUTER_JUMP = (parameter) => {
    router.push(parameter)
  }

  const GET_ROUTE = () => {
    return route
  }

  return {
    ROUTER_JUMP,
    GET_ROUTE,
  }
}

export const filterAsyncRoute = (asnycRoute: any, routes: any) => {
  return asnycRoute.filter((item: any) => {
    if (routes.includes(item.name)) {
      if (item.children && item.children.length > 0) {
        //333账号:product\trademark\attr\sku
        item.children = filterAsyncRoute(item.children, routes)
      }
      return true
    }
  })
}
